package sale.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;

import client.entities.ClientVO;
import sale.entities.ArticleBillvo;

public class FacturaVO implements Serializable {

	private static final long serialVersionUID = 1L;
	private int primaryKey;
	private ClientVO client;
	private Date date;
	private ArrayList<ArticleBillvo> arts;
	private double total, totaltotalConDesc; // con descuento
	private double descuento;
	private SaleVO sale;

	public ClientVO getClient() {
		return client;
	}

	public void setClient(ClientVO client) {
		this.client = client;
		this.sale.setClient(client);
	}

	public Date getDate() {
		return date;
	}
	public ArrayList<ArticleBillvo> getArts() {
		return arts;
	}
	public double getTotal() {
		return total;
	}
	public int getPrimaryKey() {
		return primaryKey;
	}
	public double getTotaltotalConDesc() {
		return totaltotalConDesc;
	}

	public double getDescuento() {
		return descuento;
	}

	public void setDescuento(double descuento) {
		this.descuento = descuento;
		BigDecimal aux = new BigDecimal(this.total);
		aux = aux.multiply(new BigDecimal(1-descuento/100));
		this.totaltotalConDesc = aux.doubleValue();
	}
	public SaleVO getSale() {
		return sale;
	}

	public FacturaVO(int primaryKey, ClientVO client, Date date,
			ArrayList<ArticleBillvo> arts, double total, double totalConDesc,
			double descuento) {
		this.primaryKey = primaryKey;
		this.client = client;
		this.date = date;
		this.arts = arts;
		this.total = total;
		this.totaltotalConDesc = totalConDesc;
		this.descuento = descuento;
	}

	public FacturaVO(Date date, ArrayList<ArticleBillvo> arts, double total, SaleVO sal) {
		this.date = date;
		this.arts = arts;
		this.total = total;
		this.totaltotalConDesc = total;
		this.sale = sal;
		sal.setCloseDate(date);
	}
}
